// 节流:触发函数事件后，短时间间隔内无法连续调用，只有上一次函数执行后，过了规定的时间间隔，才能进行下一次的函数调用。
let lastCall = 0
export function throttle(fn, delay) {
	const now = new Date().getTime();
	if (now - lastCall < delay) {
		return
	}
	lastCall = now
	fn.apply(this, arguments)
}
// 防抖
let timer
export function debounce(fn, delay) {
	clearTimeout(timer)
	timer = setTimeout(() => {
		fn();
	}, delay);
}

export function deepClone(obj) {
	let objClone = Array.isArray(obj) ? [] : {};
	if (obj && typeof obj === 'object') {
		for (let key in obj) {
			if (obj[key] && typeof obj[key] === 'object') {
				objClone[key] = deepClone(obj[key]);
			} else {
				objClone[key] = obj[key]
			}
		}
	}
	return objClone;
}